package com.y.core.listener;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextStoppedEvent;
import org.springframework.stereotype.Component;

import com.y.core.plugins.PluginManager;
/**
 * 关闭监听器
 */
@Component
public class StopListener implements ApplicationListener<ContextStoppedEvent> {
	@Override
	public void onApplicationEvent(ContextStoppedEvent event) {
		if (event.getApplicationContext().getParent() == null) {
			destroyPlugin();
		}
	}
	/**
	 * 插件的停用
	 */
	private void destroyPlugin() {
		PluginManager.init().stop();
	}
}
